package kr.hkit.androidcomplete03.ch25;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class WordDbHelper extends SQLiteOpenHelper {
	public final static String DB_NAME = "EngWord.db";
	public final static int DB_VERSION = 1;
	public final static String TAG = "SQLiteOpenHelper";
	
	public WordDbHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
		Log.d(TAG, "WordDbHelper()");
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql = "create table dic ( "
				+ "_id integer primary key autoincrement, "
				+ "eng text, "
				+ "han text"
				+ ");";
		Log.d(TAG, "onCreate() "+ sql);
		db.execSQL(sql);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.d(TAG, "onUpgrade() oldVersion = " + oldVersion + " newVersion = " + newVersion);
		db.execSQL("drop table if exists dic");
		onCreate(db);
	}

}
